$(function (){
    let $downloadbtn = $(".test-download");
    let $url = $(location).attr("href").split('=')[8];

    $downloadbtn.click(function (){
        let sIdc = $("#idc option:selected").val();
        let sIdcr = $("#idcr option:selected").val();
        let sTransfer = $("#transfer option:selected").val();
        let sPupdate = $("#pupdate option:selected").val();
        let sObip = $("#obip option:selected").val();
        let sOffline = $("#offline option:selected").val();
        let sSupplier = $("#supplier option:selected").val();
        let sRemarks = decodeURIComponent($url);
        // let sRemarks = $("#remarks option:selected").val();


        if(sIdc === '0' && sIdcr === '0' && sTransfer === '0' && sPupdate === '0'
                 && sObip === '0' && sOffline === '0' && sSupplier === '0' && sRemarks === '0'){
            return message.showError("无数据可下载")
        }

        var json  = {
            "idc_id":sIdc,
            "idcr_id":sIdcr,
            "transfer_id":sTransfer,
            "pupdate_id":sPupdate,
            "obip_id":sObip,
            "offline_id":sOffline,
            "supplier_id":sSupplier,
            "remarks_id": sRemarks,
        };

        var form = $("<form>");
        form.attr('style', 'display:none');
        form.attr('target', '');
        form.attr('method', 'post'); //请求方式
        form.attr('action', '/searches-transfer/');//请求地址

        var input1 = $('<input>');//将你请求的数据模仿成一个input表单
        input1.attr('type', 'hidden');
        input1.attr('name', 'json');//该输入框的name
        input1.attr('value',JSON.stringify(json));//该输入框的值

        $('body').append(form);
        form.append(input1);

        form.submit();
        form.remove();
    });

});